package com.ycsj.goldmedalnewconcept.common.adapter;


import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ycsj.common.utils.DateUtils;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.common.bean.CommentInfo;

import java.util.List;

/**
 * 评论列表的适配器
 * Created by Administrator on 2018/6/29 0029.
 */

public class CommentRvAdapter extends BaseQuickAdapter<CommentInfo.DataBean.CommentBean, BaseViewHolder> {

    private Context context;

    public CommentRvAdapter(Context context, int layoutResId, @Nullable List<CommentInfo.DataBean.CommentBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, CommentInfo.DataBean.CommentBean item) {
        //评论人
        TextView tvName = helper.getView(R.id.tv_name);
        String name = item.getUSER_NAME();

        //只显示姓后面用*隐藏
        String subName = name.substring(1);
        //取姓
        String xing = String.valueOf(name.charAt(0));
        tvName.setText(xing +subName.replaceAll(".","*"));

        //评论时间
        TextView tvTime = helper.getView(R.id.tv_time);
        tvTime.setText(DateUtils.fromToday(item.getTIME()));

        //评论的内容
        TextView tvComment = helper.getView(R.id.tv_comment);
        tvComment.setText(item.getCONTENT());

    }
}
